<template>
  <div id="app">
    <router-view v-if="isRouterAlive" />
  </div>
</template>

<script>
import screenfull from 'screenfull'
export default {
  name: 'App',
  provide() {
    return {
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true
    }
  },
  mounted() {
    this.globalClick(() => {
      this.changeScreenful()
    })
  },
  methods: {
    reload() {
      this.isRouterAlive = false
      this.$nextTick(function() {
        this.isRouterAlive = true
      })
    },
    changeScreenful() {
      if (this.$route.path.indexOf('datav') > -1) {
        if (!screenfull.enabled) {
          this.$message({
            message: '您当前用的浏览器不支持全屏',
            type: 'warning'
          })
          return false
        }
        screenfull.toggle()
      }
    }
  }
}
</script>
